package org.ticketing.controller;

import javax.persistence.*;

import org.ticketing.model.*;

public class AccountManager {
	
	public void login(String username, String pwd) {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("DB");
		EntityManager manager = factory.createEntityManager();
		
		if(manager.contains(new User(username, pwd))) {
			// Redirect to private area
			// Enable link to private area
			// Store data about actual user?
		}	
	}
	
	public void logout() {
		// Disable link to private area
		// Flush data about actual user?
	}
	
	public void registration(String username, String pwd) {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("DB");
		EntityManager manager = factory.createEntityManager();
		
		// Add control about in-use usernames
		
		manager.persist(new User(username, pwd));
	}
}
